<template>
    <div>
        <h1>科室添加</h1>
        姓名<input type="text" v-model="info.names">
        <input type="button" value="查询" @click="getlist">
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>Id</td>
                    <td>姓名</td>
                    <td>头像</td>
                    <td>科室</td>
                    <td>创建日期</td>
                </tr>

                <tr v-for="itme in data.list">
                    <td>{{ itme.YSId }}</td>
                    <td>{{ itme.YSName }}</td>
                    <td><img :src="itme.Img" width="60" height="60"></td>
                    <td>{{ itme.Name }}</td>
                    <td>{{ itme.YsTime }}</td>
                </tr>
            </tbody>
        </table>
        <input type="button" value="首页" @click="gopage(1)">
        <input type="button" value="上一页" @click="gopage(info.pageindex - 1)">
        <input type="button" value="下一页" @click="gopage(info.pageindex + 1)">
        <input type="button" value="尾页" @click="gopage(data.totalpage)">
    </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import axios from 'axios';
import { useRouter, useRoute } from 'vue-router';
const router = useRouter();
const route = useRoute();
let info: any = reactive({
    names: '',
    pageindex: 1,
    pagesize: 2
})
let data: any = reactive({
    list: [],
    totalcount: '',
    totalpage: ''

})
onMounted(() => {
    getlist();
})
const getlist = () => {
    axios({
        url: '/api/YS/YSShow',
        method: 'get',
        params: info
    })
        .then((res) => {
            console.log(res);
            Object.assign(data, res.data)

        })
}
///===========================================分页
const show = () => {
    info.pageindex = 1;
    getlist();
}
const gopage = (num: any) => {
    if (num < 1) {
        info.pageindex = 1;
        return;
    }
    if (num > data.totalpage) {
        info.pageindex = data.totalpage
        return;
    }
    info.pageindex = num;
    getlist()
}
</script>

<style scoped></style>